package org.liuyunfeng.web;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.CountDownLatch;

/**
 * @author: TanJingyu
 * @create: 2022-06-21 14:38
 **/
@RestController
@RequestMapping("/countDownLatch")
public class CountDownLatchController {
    private final CountDownLatch countDownLatch = new CountDownLatch(3);


    @GetMapping
    public String a() throws InterruptedException {
        countDownLatch.await();
        return "success...";
    }

    @GetMapping("/countDown")
    public long b() {
        countDownLatch.countDown();
        return countDownLatch.getCount();
    }

}

    